<?php
error_reporting(false);
  require_once "function.php";
 if($_GET['isbn']) $book=M()->select('book','*','ISBN="'.$_GET['isbn'].'"')[0];
 ?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title><?php echo $_GET["isbn"]?"修改图书":"添加图书" ?></title>
  <link rel="stylesheet" href="public/semantic.min.css" media="screen" title="no title" charset="utf-8">
  <link rel="stylesheet" href="public/index.css" media="screen" title="no title" charset="utf-8">
</head>
<body>
  <div class="ui  container two column grid">
    <div class="column" >
      <h4 class="ui top attached block header">
         <?php echo $_GET["isbn"]?"修改图书":"添加图书" ?>
      </h4>
      <form class="ui form bottom attached segment ">
        <div class="field">
          <label>ISBN</label>
          <input type="text" name="ISBN"  value="<?php echo $book['ISBN']; ?>">
        </div>
        <div class="field">
          <label>书名</label>
          <input type="text" name="name" value="<?php echo $book['name']; ?>" >
        </div>
        <div class="field">
          <label>作者</label>
          <input type="text" name="author" value="<?php echo $book['author']; ?>" >
        </div>
        <div class="field">
          <label>出版社</label>
          <input type="text" name="press" value="<?php echo $book['press']; ?>">
        </div>
        <div class="field">
          <label>定价</label>
          <input type="number" name="price"  value="<?php echo $book['price']; ?>">
        </div>
        <div class="field">
          <label>折扣</label>
          <input type="text" name="discount" value="<?php echo $book['discount']; ?>">
        </div>
        <div class="field">
          <label>图书类别</label>
          <input type="text" name="type" value="<?php echo $book['type']; ?>" >
        </div>
        <div class="field">
          <label>图书概况</label>
          <input name="overview" value="<?php echo $book['overview']; ?>"></input>
        </div>
        <div class="field">
          <label>库存数量</label>
          <input type="number" name="stock" value="<?php echo $book['stock']; ?>" >
        </div>
        <!-- <div class="field">
          <div class="ui checkbox">
            <input type="checkbox" tabindex="0"  >
            <label>同意用户协议</label>
          </div>
        </div> -->
        <a class="ui button reg green" type="botton"><?php echo $_GET["isbn"]?"确认修改":"确认添加" ?></a>
      </form>
    </div>

  </div>

  <script src="public/jquery-2.2.0.js" charset="utf-8"></script>
  <script src="public/index.js" charset="utf-8"></script>
  <script>
  $('.reg').click(function(){
    var data=getFormData('form');
    $.post('action.php?c=book&m=<?php echo $_GET["isbn"]?"update":"add" ?>',{data:data},function(data){
       alert('操作成功!');
    })
  })
  </script>
</body>
</html>
